package com.example.hxds.mis.api.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.annotation.SaMode;
import cn.dev33.satoken.stp.StpUtil;
import com.example.hxds.common.util.PageUtils;
import com.example.hxds.common.util.R;
import com.example.hxds.mis.api.controller.form.AcceptCommentAppealForm;
import com.example.hxds.mis.api.controller.form.HandleCommentAppealForm;
import com.example.hxds.mis.api.controller.form.SearchAppealContentForm;
import com.example.hxds.mis.api.controller.form.SearchOrderByPageForm;
import com.example.hxds.mis.api.service.OrderService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.HashMap;

/**
 * @Author XUYANG
 * @Date 2024-04-08 16:12
 */
@RequestMapping("/comment")
@RestController
@Tag(name = "OrderCommentController",description = "订单评价模块web管理接口")
public class OrderCommentController {
    @Resource
    private OrderService orderService;
    @PostMapping("/acceptCommentAppeal")
    @SaCheckPermission(value = {"ROOT","DRIVER:SELECT"},mode = SaMode.OR)//权限限制
    @Operation(summary = "受理评价申诉")
    public R acceptCommentAppeal(@RequestBody @Valid AcceptCommentAppealForm form){
        int userId= StpUtil.getLoginIdAsInt();
        form.setUserId(userId);
        orderService.acceptCommentAppeal(form);
        return R.ok();
    }
    @PostMapping("/handleCommentAppeal")
    @SaCheckPermission(value = {"ROOT","DRIVER:SELECT"},mode = SaMode.OR)//权限限制
    @Operation(summary = "受理评价申诉")
    public R handleCommentAppeal(@RequestBody @Valid HandleCommentAppealForm form){
        int userId= StpUtil.getLoginIdAsInt();
        form.setUserId(userId);
        orderService.handleCommentAppeal(form);
        return R.ok();
    }
    @PostMapping("/searchAppealContent")
    @SaCheckPermission(value = {"ROOT","DRIVER:SELECT"},mode = SaMode.OR)//权限限制
    @Operation(summary = "查询审批工作流内容")
    public R searchAppealContent(@RequestBody @Valid SearchAppealContentForm form){
        HashMap map=orderService.searchAppealContent(form);
        return R.ok().put("result",map);
    }
}
